import EventMgr from "../../../../Core/Event/EventMgr";
import UICore from "../../../../Core/Res/UICore";
import SdkTool from "../../../../Core/Sdk/SdkTool";
import { ViewManager } from "../../base/ViewManager";
import { GameModels } from "../../socket/GameModels";
import AbstractUIWindow from "../../window/AbstractUIWindow";
import * as fgui from "fairygui-cc";

export class SidebarWindow extends AbstractUIWindow {
    private getReward: fgui.GButton;
    private goto: fgui.GButton;
    protected getResList(): Array<string> {
        return ["Main"];
    }
    protected onInit(): void {
        this._view = UICore.createObject("Main", "SidebarWindow").asCom;
    }
    protected onShow(): void {
        EventMgr.on(`event_RespDouYinSide`, this.event_RespDouYinSide, this);
        this.getReward.onClick(this.clickgetReward, this);
        this.goto.onClick(this.clickgoto, this);
        this.getReward.visible = SdkTool.ins.isSidebar;
        this.goto.visible = !SdkTool.ins.isSidebar;
    }
    private event_RespDouYinSide(): void {
        this.close();
    }
    private clickgoto(): void {
        this.close();
        SdkTool.ins.sdk.navigateToScene();
    }
    private clickgetReward(): void {
        GameModels.support.send_ReqDouYinSide();
    }
}